<template>
  <div class="home">
  <el-container class="container">
  <el-header>
    <div class="header">
        <img src="../assets/logo2.jpg" alt="" class="header_logo">
        <div class="header_div01">
            <el-button type="primary" plain>消息</el-button>
            <el-button type="primary" plain>设置</el-button>
            <el-button type="primary" plain @click="quit()">安全退出▼</el-button>

        </div>
    </div>
  </el-header>
  <el-container>
    <el-aside width="200px">
      <p class="admin">当前用户：{{uname}}</p>
       <el-menu
       router
       unique-opened
      default-active="2"
      class="el-menu-vertical-demo">
      <!-- 一级菜单 -->
      <el-submenu :index="v.id+''" v-for="(v,index) in menulist" :key="v.id">
        <template slot="title">
          <i :class="icons[index]"></i>
          <span class="icontitle">{{v.authName}}</span>
        </template> 
        <!-- 二级菜单 -->
       <el-menu-item :index="v1.path" v-for="v1 in v.children" :key="v1.id">{{v1.authName}}</el-menu-item>
      </el-submenu>
      
    </el-menu>
    </el-aside>

    <el-main>
         <!--  -->
          <router-view></router-view>
    </el-main>

  </el-container>
</el-container>
  </div>
</template>
<script>
export default {
    data() {
      return {
        menulist: [],
        icons:[
          "iconfont icon-yonghu",
          "iconfont icon-quanxian",
          "iconfont icon-shangpin",
          "iconfont icon-guanli",
          "iconfont icon-shuju",
        ],
        uname:""
      }
    },
     methods: {
      quit(){
        sessionStorage.removeItem("token")
        this.$message({
          message: '你已安全退出',
          type: 'success'
        });
        this.$router.push("/login")
      },
      async getmenus(){
        await this.axios.get("menus").then(res=>{
          console.log(res.data.data)
          this.menulist=res.data.data
         
        })
      }
    },
    mounted(){
       this.uname=sessionStorage.getItem("uname")
      this.getmenus();
    }
}
</script>
<style lang="scss" scoped>
.home{
  height: 100%;
  .header{
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
     .header_logo{
        width: 200px;
        height:50px;
      }
    .header_div01{
    }
  }
 
  .el-header{
    background-color: #0097da;
    color: #333;
    padding: 50px 100px;
  }
  .container{
    height: 100%;
  }
  .el-aside {
    background-color: #aab2bb;
    color: #333;
    text-align: center;
    height: 100%;
    .icontitle{
      margin-left: 5px;
    }
  }
  
  .el-main {
    background-color: #E9EEF3;
    color: #333;
    height: 100%;
    padding: 0;
    .el-table__header{
      background-color: #909399;
    }
  }
  
  body > .el-container {
    margin-bottom: 40px;
    height: 100%;
  }
  
  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }
  
  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }
}
  
</style>